using System;
using System.Collections.Generic;
using System.Text;
using System.Globalization;

namespace Weazel.Toad.Application.Items
{
    public class GezelSimulationOutputWriter
      : System.IO.TextWriter
    {
        public delegate void OutputReadyEventHandler(string text);

        public event OutputReadyEventHandler OutputReadyEvent;

        public GezelSimulationOutputWriter()
        {
        }

        public override Encoding Encoding
        {
            get { throw new NotImplementedException(); }
        }

        public override IFormatProvider FormatProvider
        {
            get { return System.Console.Out.FormatProvider; }
        }

        private void WriteInternal(object value)
        {
            if (OutputReadyEvent != null)
                OutputReadyEvent(value.ToString());
        }

        public override void Write(object value)
        {
            WriteInternal(value);
        }

        public override void Write(string value)
        {
            WriteInternal(value);
        }

        public override void WriteLine(string format, object arg0)
        {
            WriteInternal(string.Format(format, arg0));
        }

        public override void WriteLine(string format, object arg0, object arg1)
        {
            WriteInternal(string.Format(format, arg0, arg1));
        }

        public override void WriteLine(string format, object arg0, object arg1, object arg2)
        {
            WriteInternal(string.Format(format, arg0, arg1, arg2));
        }
    }
}
